﻿#functions
function ZipFiles( $zipfilename, $sourcedir ){
    [Reflection.Assembly]::LoadWithPartialName( "System.IO.Compression.FileSystem" ) > $null;
    $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
    $sourcedir = (Get-Item $sourcedir).FullName;
    [System.IO.Compression.ZipFile]::CreateFromDirectory( $sourcedir, $zipfilename, $compressionLevel, $false ) > $null;
}

cls

$workspace = "C:\Workspace\ProjectAlbatross.NET\AlbatrossShell"

Get-ChildItem -Recurse -Directory -Path $workspace -Include bin | foreach{ Remove-Item $_ -Force -Confirm:$false -Recurse ; }
Get-ChildItem -Recurse -Directory -Path $workspace -Include obj | foreach{ Remove-Item $_ -Force -Confirm:$false -Recurse ; }
Get-ChildItem -Recurse -Directory -Path $workspace -Include debug | foreach{ Remove-Item $_ -Force -Confirm:$false -Recurse ; }
Get-ChildItem -Recurse -Directory -Path $workspace -Include release | foreach{ Remove-Item $_ -Force -Confirm:$false -Recurse ; }


Get-ChildItem -Recurse -File -Path $workspace -Include *.dbmdl | foreach{ Remove-Item $_ -Force -Confirm:$false -Recurse ; }
Get-ChildItem -Recurse -File -Path $workspace -Include *.user | foreach{ Remove-Item $_ -Force -Confirm:$false -Recurse ; }
Get-ChildItem -Recurse -File -Path $workspace -Include *.suo -Hidden | foreach{ Remove-Item $_ -Force -Confirm:$false -Recurse ; }
Get-ChildItem -Recurse -File -Path $workspace -Include *.suo | foreach{ Remove-Item $_ -Force -Confirm:$false -Recurse ; }
Remove-Item  -Path $workspace\*.doc
Remove-Item -Path $workspace\*.zip

if (Test-Path $workspace\TestResults){
    Remove-Item -Path $workspace\TestResults -Recurse -Confirm:$false;
}

if(Test-Path $workspace\Albatross.Shell.Documentation\Help){
    Remove-Item -Path $workspace\Albatross.Shell.Documentation\Help -Recurse -Confirm:$false;
}

$zip = [System.String]::Format("{0:yyyy-MM-dd}.doc", [System.DateTime]::Today);

if(Test-Path c:\temp\$zip){
    Remove-Item c:\temp\$zip;
}

zipfiles -zipfilename c:\temp\$zip  -sourcedir $workspace;
Move-Item -Path c:\temp\$zip -Destination $workspace;

